package com.bolt.admin.module.test.controller;

import com.bolt.admin.module.test.dto.FruitOrderDTO;
import com.bolt.admin.module.test.service.FruitOrderService;
import com.bolt.convention.data.ResultMessage;
import com.bolt.convention.data.Results;
import com.bolt.support.query.nativequery.parall.ParallelQueryResult;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Auto Generate Javadoc
 *
 * @author 日期:2021-06-01 15:18:29
 *         查询汇总演示-水果订单表
 **/
@RestController
@RequestMapping("test/fruitOrder")
@RequiredArgsConstructor
@Api(tags = "查询汇总演示-水果订单表")
public class FruitOrderController {

    private final FruitOrderService fruitOrderService;

    @GetMapping
    public ResultMessage test() {
        List<FruitOrderDTO> datas = fruitOrderService.test();
        for (FruitOrderDTO data : datas) {
            System.out.println(data);
        }
        return Results.success(datas);
    }

    @GetMapping("/test2")
    public ResultMessage test2() {
        List<FruitOrderDTO> datas = fruitOrderService.test2();
        for (FruitOrderDTO data : datas) {
            System.out.println(data);
        }
        return Results.success(datas);
    }

    @GetMapping("/test3")
    public ResultMessage test3() {
        List<ParallelQueryResult> queryResults = fruitOrderService.test3();
        for (ParallelQueryResult data : queryResults) {
            System.out.println(data.getRows());
        }
        return Results.success();
    }

    @GetMapping("/test4")
    public ResultMessage test4() {
        Map<String,Object> param = new HashMap<>();
        param.put("key",1);
        List  queryResults = fruitOrderService.test42(param);
        return Results.success(queryResults);
    }


    @GetMapping("/test5")

    public ResultMessage test5() {
        Map<String,Object> param = new HashMap<>();
        param.put("key",1);
        fruitOrderService.test43(param);
        List  queryResults = fruitOrderService.test42(param);
        return Results.success(queryResults);
    }
}